package two_xia.ex5.Demo03;

import java.io.*;

public class Client {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        Address a = new Address("福建省福州市");
        Customer c1 = new Customer("小明", a);
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        ObjectOutputStream oos = new ObjectOutputStream(bos);
        oos.writeObject(c1);
        oos.flush();
        ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(bos.toByteArray()));
        Customer c2 = (Customer) ois.readObject();
        System.out.println("修改前：");
        System.out.println(c1.toString());
        System.out.println(c2.toString());
        System.out.println();
        System.out.println("修改后：");
        c1.setName("小红");
        a.setAddress("广东省广州市");
        System.out.println(c1.toString());
        System.out.println(c2.toString());

    }
}